package org.jrill;

import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * Standard human workflow participant identified by user id.
 * @author K.Waga
 */
public class User implements Participant, Serializable {
    private static final long serialVersionUID = -7692109144430158995L;

    protected Serializable id;

    protected String userName;

    protected String mailAddress;

    /**
     * 
     */
    public User() {

    }

    /**
     * Full constructor
     * @param id
     * @param userName
     * @param mailAddress
     */
    public User(Serializable id, String userName, String mailAddress) {
        this.id = id;
        this.userName = userName;
        this.mailAddress = mailAddress;
    }

    public String getMailAddress() {
        return mailAddress;
    }

    public void setMailAddress(String mailAddress) {
        this.mailAddress = mailAddress;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Serializable getId() {
        return this.id;
    }

    public void setId(Serializable id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final User other = (User) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if ((this.userName == null) ? (other.userName != null) : !this.userName.equals(other.userName)) {
            return false;
        }
        if ((this.mailAddress == null) ? (other.mailAddress != null) : !this.mailAddress.equals(other.mailAddress)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 71 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 71 * hash + (this.userName != null ? this.userName.hashCode() : 0);
        hash = 71 * hash + (this.mailAddress != null ? this.mailAddress.hashCode() : 0);
        return hash;
    }

    public String getName() {
        return getUserName();
    }

    public String getAddress() {
        return getMailAddress();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this).append("id", id).append("userName", userName).append("mailAddress", mailAddress).toString();
    }

}
